#ifndef EZAX_COMPONENT_H
#define EZAX_COMPONENT_H

#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */

#ifndef OMX_MAX_DET_FACES_NUM
#define OMX_MAX_DET_FACES_NUM 256
#endif

#ifndef OMX_DEFAULT_FEATURE_SIZE
#define OMX_DEFAULT_FEATURE_SIZE 4096
#endif

#ifndef OMX_MAX_DET_HUM_NUM
#define OMX_MAX_DET_HUM_NUM 128
#endif

#ifndef OMX_MAX_MBG_BOX_NUM
#define OMX_MAX_MBG_BOX_NUM 256
#endif

typedef enum EzaxOmxImageFormat_e {
	EZAX_OMX_YUV420_SP = 0x02,
	EZAX_OMX_YVU420_SP = 0x04,
	EZAX_OMX_BGRA  = 0x09,
} ezax_omx_img_fmt_e;

typedef struct ezax_omx_imres
{
	/* picture resolution */
	int w; int h;
}ezax_omx_imres_t;


typedef struct ezax_omx_freq
{
	/*dev_id; freq*/
	int id; int freq;
} ezax_omx_freq_t;


typedef struct ezax_omx_face_kpts {
	float kpts[10];
} ezax_omx_face_kpts_t;


typedef struct ezax_omx_init_cfg {
	unsigned int width;
	unsigned int height;
	char *ezbStr;
	char *binStr;
} ezax_omx_init_cfg_t;


typedef struct ezax_omx_rt
{
	/* left top */
	int x0;	int y0;
	/* right bottom */
	int x1;	int y1;
	/* class */
	int c;
	/* score */
	float s;
	/* id */
	int id;
	/* area */
	int area;
	/* exit */
	int exist;
	/* input extern information such as ezax_face_kpts_t */
	void *in_ex_inform;
	/* output extern information*/
	void *out_ex_inform;
	/* rsved */
	int rev;
}ezax_omx_rt_t;


typedef struct ezax_omx_boxes
{
	/* roi boxes */
	ezax_omx_rt_t *pRect;
	/* rect num */
	int num;
	/* */
	unsigned int nUID;
	/* rzv inform */
	void *rzv;
} ezax_omx_boxes_t;


typedef struct ezax_omx_img_handle {
	/* vir addr*/
	void *pVir;
	void *pVir_UV;
	/* phy addr*/
	unsigned int pPhy;
	unsigned int pPhy_UV;
	/* size */
	int sz;
	/* fmt */
	int fmt;
	/* iw */
	int w;
	/* ih */
	int h;
	/* channels */
	int c;
	/* wstride */
	int stride;
	/* color matrixs */
	int csc_mode;
} ezax_omx_img_handle_t;

typedef struct ezax_omx_img
{
	/* img_handle */
	ezax_omx_img_handle_t img_handle;
	/* valid roi */
	ezax_omx_rt_t roi;
	/* */
	unsigned int nUID;
	/* reved */
	unsigned int rzv;
} ezax_omx_img_t;


typedef struct ezax_omx_img_batch
{
	/* batch images */
	ezax_omx_img_t *pImg;
	/* batch num */
	unsigned int nNum;
} ezax_omx_img_batch_t;


typedef struct ezax_omx_img_rois
{
	/* img_handle */
	ezax_omx_img_handle_t img_handle;
	/* valid roi */
	ezax_omx_rt_t *roi;
	/* roi num */
	int roi_num;
	/* input extern information such as ezax_face_kpts_t*/
	unsigned int nUID;
	/* reserved */
	unsigned int rzv;
} ezax_omx_img_rois_t;



/*********************************************************************
***************************face det**********************************
*********************************************************************/

typedef struct ezax_omx_facedet_cfg {
	unsigned int width;
	unsigned int height;
	char *model_rootpath; //base address
	int det_mode;
	int fdet_max_size;
	int fdet_min_size;
	ezax_omx_rt_t roi;
} ezax_omx_facedet_cfg_t;



/*********************************************************************
***************************face qulity**********************************
*********************************************************************/

typedef struct eazx_omx_facequality_cfg {
	ezax_omx_init_cfg_t base_init_cfg;
} ezax_omx_facequality_cfg_t;

typedef struct ezax_omx_facequality_rt
{
    int quality_score;
}ezax_omx_facequality_rt_t;



/*********************************************************************
***************************head pose**********************************
*********************************************************************/

typedef struct eazx_omx_headpose_cfg {
	ezax_omx_init_cfg_t base_init_cfg;
} ezax_omx_headpose_cfg_t;

typedef struct ezax_omx_headpose_rt
{
    float head_pose[3];
    float head_pose_pts[3];
}ezax_omx_headpose_rt_t;


/*********************************************************************
***************************face track**********************************
*********************************************************************/


typedef struct eazx_omx_facetrack_cfg {
	unsigned int width;
	unsigned int height;
	char *model_rootpath;
	int max_track_frames;
	int max_track_faces;
	int visual_track_thresh;
	int use_fast_track;
	float new_target_thresh;/*add new target when detect score>new_target_thresh*/
	float match_thresh;/*0.2-1.0f*/
	int   max_lost_hold_num;/*0-100*/
	float lost_hold_rematch_thresh;/*0-1*/
} ezax_omx_facetrack_cfg_t;

typedef struct ezax_omx_facetrack_rt
{
    ezax_omx_face_kpts_t face_kpts;
    int facetrk_flag;
}ezax_omx_facetrack_rt_t;

/*********************************************************************
**************************** mbg md **********************************
*********************************************************************/

typedef struct ezax_omx_mbg_md_cfg_s
{
    int fmt_in; // input image format, 2:YUV420_SP  9:NNA_BGRA
    int iw;  // input image width
    int ih; // input image height
    int fg_thr; // foreground filter threshold value, suggest setting range [5, 70]
    int dilate_times; // do dilate times, suggest setting range [1, 5], if msk_filter_strength>0, dilate_times recommend the val set above 1
    int msk_filter_strength;  // msk foreground picture do filter in vertical direction, 0: no filter 1: low-strength  2: mid-strength  3: high-strength  
}ezax_omx_mbg_md_cfg_t;


typedef struct ezax_omx_mbg_param
{
	int input_width;
	int input_height;
	/*! POOLING BLK_W/BLK_H */
	int pool_w;
	int pool_h;
	/*! FG MASK Threshold */
	int threshold_enable;
	int threshold;
	/*! BG update alpha */
	int alpha;
	/*! Scene change */
	int reset_flag;
	/*! Pooling mask threshold */
	int mask_threshold;
}ezax_omx_mbg_param_t;


/*********************************************************************
**************************** face reg ********************************
*********************************************************************/

typedef struct ezax_omx_facereg_cfg {
	ezax_omx_init_cfg_t base_init_cfg;
	unsigned int mask;
	ezax_omx_freq_t freq;
} ezax_omx_facereg_cfg_t;


typedef struct ezax_omx_face_feature {
	void *feature_ref;
	int feature_size;
	int dtype;
	float norm_value;
	unsigned int nUID;
} ezax_omx_face_feature_t;

typedef struct ezax_omx_face_compare {
	void *features;
	int features_num;
	float *features_norm;

	void *feature_ref;

	int feature_part;
	int feature_size;
	int feature_cmp_size;
	float *score;
	int max_id[3];
	int dtype;
} ezax_omx_face_compare_t;


/*********************************************************************
***************************living det*********************************
*********************************************************************/

typedef struct ezax_omx_livingdet_rt {
    int live_score;
} ezax_omx_livingdet_rt_t;

typedef struct ezax_omx_livingdet_cfg {
	char *model_rootpath;  //base address
	ezax_omx_freq_t freq;
	float rgb_exposure_time_rate;
	float rgb_exposure_dark_rate;
	int single_rgb_model;
	int living_color_enable;
	int mask_en;
	int mask_living_enable;
	float nir_avg_lum_rate; // for nir image
	int living_confidence_thr;
	int livingdet_mode;
} ezax_omx_livingdet_cfg_t;

/*********************************************************************
***************************face attr*********************************
*********************************************************************/

typedef struct ezax_omx_faceattr_cfg_s {
	ezax_omx_freq_t freq;
	char *model_rootpath;
	int enable_age_det;
	int enable_gender_det;
	int enable_glasses_det;
	int enable_mask_det;
	int enable_beard_det;
	int enable_hat_det;
	int enable_halmet_det;
}ezax_omx_faceattr_cfg_t;

typedef struct ezax_omx_faceattr_rt_s {
	int age;
	int gender;
	int glasses;
	int mask;
	int beard;
	int hat;
	int halmet;
} ezax_omx_faceattr_rt_t;


/*********************************************************************
**************************** pep det *******************************
*********************************************************************/


typedef struct ezax_omx_humdet_cfg {
	ezax_omx_init_cfg_t base_init_cfg;;
	ezax_omx_freq_t freq;
} ezax_omx_humdet_cfg_t;


/*********************************************************************
**************************** pep track ******************************
*********************************************************************/

typedef struct ezax_omx_peptrk_cfg
{
	int  color_fmt;
	int  visual_track_thresh;
	int  max_track_objs;
	int  max_track_frames;
	int  use_fast_track;
	int  rev[5];
	float new_target_thresh;/*add new target when detect score>new_target_thresh*/
	float match_thresh;/*0.2-1.0f*/
	int   max_lost_hold_num;/*0-100*/
	float lost_hold_rematch_thresh;/*0-1*/
}ezax_omx_peptrk_cfg_t;

/********************************************************************
**************************** face clarity ***************************
*********************************************************************/

typedef struct ezax_omx_faceclarity_cfg_s {
	ezax_omx_init_cfg_t base_init_cfg;;
}ezax_omx_faceclarity_cfg_t;

typedef struct ezax_omx_faceclarity_rt
{
	int faceclarity_score;
	int faceclarity_level;
}ezax_omx_faceclarity_rt_t;

/********************************************************************
**************************** sface det ***************************
*********************************************************************/

typedef struct eazx_omx_sfacedet_cfg {
	ezax_omx_init_cfg_t base_init_cfg;
	int fmt;
} ezax_omx_sfacedet_cfg_t;

#ifdef __cplusplus
}
#endif /* __cplusplus */

#endif
